home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C ++ / Frameworks / MacZoop 1.6.5 / More Classes / Undo / ZUndoTask.cpp next >
Encoding:
C/C++ Source or Header  |  1997-07-21  |  2.2 KB  |  88 lines  |  [TEXT/CWIE]

  1. /*************************************************************************************************
  2. *
  3. *
  4. *            ObjectMacZapp        -- a standard Mac OOP application template
  5. *
  6. *
  7. *
  8. *            ZUndoTask.cpp            -- a generic object for implementing Undo
  9. *
  10. *
  11. *
  12. *
  13. *
  14. *            © 1996, Graham Cox
  15. *
  16. *
  17. *
  18. *
  19. *************************************************************************************************/
  20.  
  21. #include    "ZUndoTask.h"
  22. #include    "ZWindow.h"
  23. #include    "MacZoop.h"
  24.  
  25. /*------------------------------***  CONSTRUCTOR  ***--------------------------------*/
  26.  
  27. ZUndoTask::ZUndoTask( Str63 aTaskString, ZWindow*    aTarget)
  28. {
  29.     CopyPString( aTaskString, taskString );
  30.     itsTarget = aTarget;
  31.     undone = FALSE;
  32.     isFirstTask = FALSE;
  33. }
  34.  
  35.  
  36. /*-------------------------------------***  DO  ***-------------------------------------*/
  37. /*    
  38. perform the task. This is normally overridden to do something useful! You should call the
  39. inherited method to maintain the status flag.
  40. ----------------------------------------------------------------------------------------*/
  41.  
  42. void    ZUndoTask::Do()
  43. {
  44.     undone = FALSE;
  45.  
  46.     if ( itsTarget && isFirstTask )
  47.         itsTarget->SetDirty( TRUE );
  48. }
  49.  
  50.  
  51. /*------------------------------------***  UNDO  ***------------------------------------*/
  52. /*    
  53. undo the task performed by Do. Normally overridden- call the inherited method to maintain
  54. the status flag.
  55. ----------------------------------------------------------------------------------------*/
  56.  
  57. void    ZUndoTask::Undo()
  58. {
  59.     undone = TRUE;
  60.     
  61.     if ( itsTarget && isFirstTask )
  62.         itsTarget->SetDirty( FALSE );
  63. }
  64.  
  65.  
  66. /*------------------------------------***  REDO  ***------------------------------------*/
  67. /*
  68. override if your redo is different from your Do. Normally they are not so you don't need
  69. to override this in most cases.    
  70. ----------------------------------------------------------------------------------------*/
  71.  
  72. void    ZUndoTask::Redo()
  73. {
  74.     Do();
  75. }
  76.  
  77.  
  78. /*------------------------------***  GETTASKSTRING  ***---------------------------------*/
  79. /*
  80. returns the task's straing. Normally only called from the application to maintain the
  81. wording in the Edit menu.
  82. ----------------------------------------------------------------------------------------*/
  83.  
  84. void    ZUndoTask::GetTaskString( Str63 aTaskStr )
  85. {
  86.     CopyPString( taskString, aTaskStr );
  87. }
  88.